import React from 'react';
// 说明文档：https://github.com/jamiebuilds/react-loadable
import Loadable from 'react-loadable';


export function Loading(props) {
    if (props.error) {
        console.log('', props);
        return <div>请求失败! <button onClick={props.retry}>重试</button></div>;

    } else if (props.timedOut) {
        return <div>请求超时... <button onClick={props.retry}>重试</button></div>;

    } else if (props.pastDelay) {
        return <div>请求中...</div>;
    }

    return null;
}

export default function(loader) {
    return Loadable({
        loader,
        loading: Loading,
    });
}
